package cn.yunhe.servlet;

import net.sf.json.JSONObject;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class DateOneServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
 request.setCharacterEncoding("UTF-8");
 response.setCharacterEncoding("UTF-8");
        String name= request.getParameter("name");
String age= request.getParameter("age");
        System.out.println("页面传过来的值name="+name+"页面传过来的值age="+age);
        response.setContentType("UTF-8");
        PrintWriter out =response.getWriter();
        JSONObject jsonObject=new JSONObject();
        jsonObject.put("name","zhangsan");
        out.print(jsonObject);

    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
